import './scss/index.scss'
import './common/global'
import utils from './common/utils'
import componentWraps from './common/componentWraps'
import type { App, Component } from 'vue'

export const sleep = utils.sleep.bind(utils)
export const toast = utils.toast.bind(utils)
export const alert = componentWraps.alert.bind(componentWraps)
export const getEl = utils.getEl.bind(utils)
export const throttle = utils.throttle.bind(utils)
export const debounce = utils.debounce.bind(utils)
export { setLang } from './lang'
export default {
    install(app: App) {
        let loadedModules = import.meta.glob('./components/*.vue', { eager: true }) as Record<string, { default: Component }>
        let componentModuleList = Object.entries(loadedModules)
        componentModuleList.forEach(([filePath, componentConfig]) => {
            const componentName = componentConfig.default.name || filePath.split('/').at(-1)!.replace(/\.vue$/, '')
            app.component(componentName, componentConfig.default)
        })
    }
}

// components start
export { default as AAlert } from '@/components/AAlert.vue'
export { default as ABadge } from '@/components/ABadge.vue'
export { default as AButton } from '@/components/AButton.vue'
export { default as ACollapse } from '@/components/ACollapse.vue'
export { default as AControlGroup } from '@/components/AControlGroup.vue'
export { default as ADropdown } from '@/components/ADropdown.vue'
export { default as ADropdownButtonGroup } from '@/components/ADropdownButtonGroup.vue'
export { default as AFakeimg } from '@/components/AFakeimg.vue'
export { default as AFitimg } from '@/components/AFitimg.vue'
export { default as AForm } from '@/components/AForm.vue'
export { default as AFormItem } from '@/components/AFormItem.vue'
export { default as AInputCheckBox } from '@/components/AInputCheckBox.vue'
export { default as AInputCheckBoxSingle } from '@/components/AInputCheckBoxSingle.vue'
export { default as AInputDate } from '@/components/AInputDate.vue'
export { default as AInputImage } from '@/components/AInputImage.vue'
export { default as AInputImageMulti } from '@/components/AInputImageMulti.vue'
export { default as AInputNumber } from '@/components/AInputNumber.vue'
export { default as AInputPassword } from '@/components/AInputPassword.vue'
export { default as AInputRadioButton } from '@/components/AInputRadioButton.vue'
export { default as AInputRichText } from '@/components/AInputRichText.vue'
export { default as AInputSearch } from '@/components/AInputSearch.vue'
export { default as AInputSelect } from '@/components/AInputSelect.vue'
export { default as AInputSelectMulti } from '@/components/AInputSelectMulti.vue'
export { default as AInputSlider } from '@/components/AInputSlider.vue'
export { default as AInputString } from '@/components/AInputString.vue'
export { default as AInputSwitch } from '@/components/AInputSwitch.vue'
export { default as AInputTextarea } from '@/components/AInputTextarea.vue'
export { default as AInputTree } from '@/components/AInputTree.vue'
export { default as AInputTreeMulti } from '@/components/AInputTreeMulti.vue'
export { default as ALabel } from '@/components/ALabel.vue'
export { default as ALineHeader } from '@/components/ALineHeader.vue'
export { default as AMenu } from '@/components/AMenu.vue'
export { default as AModal } from '@/components/AModal.vue'
export { default as APaging } from '@/components/APaging.vue'
export { default as APopup } from '@/components/APopup.vue'
export { default as AScrollable } from '@/components/AScrollable.vue'
export { default as AScrollableH } from '@/components/AScrollableH.vue'
export { default as ATable } from '@/components/ATable.vue'
export { default as ATooltip } from '@/components/ATooltip.vue'
export { default as ATree } from '@/components/ATree.vue'
// components end